// miniprogram/pages/my/my_recharge/index.js
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    money: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  recharge: function () {
    var params = {};
    params.money = this.data.money;
    params.openId = app.openId;
    params.key="wxapp";
    app.postRequest("/rest/payconfig/recharge.htm", params, this.backRecharge);
  },
  backRecharge(res) {
    if (res.code == 0) {
      app.pay(res.pay,this.backSuccess);
    } else {
      app.showModal(res.msg);
    }
  },
  backSuccess(){
   wx.redirectTo({
     url: '/pages/my/my_account/index',
   })
  }
})